from models.models import StoreMenu
from django.http.response import JsonResponse
from models.models.RequestResult import RequestResult as Res
from django.views.decorators.csrf import csrf_exempt


# 获取首页菜单
@csrf_exempt
def get_index_menu(request):
    menus = StoreMenu.objects.all()[0:16]
    res_menus = []
    for menu in menus:
        res_menu = dict()
        res_menu["id"] = menu.id
        res_menu["menu_name"] = menu.menu_name
        res_menus.append(res_menu)
    return JsonResponse(Res.success(res_menus))
